//导出路由配置
export default [
  {
    path: "/home", //主页
    component: () => import("@/views/Home"),
    meta: {
      show: true,
      isAuther: false,
    },
  },
  {
    path: "/search/:keyword", //搜索
    component: () => import("@/views/Search"),
    meta: {
      show: true,
      isAuther: false,
    },
    name: "search",
  },
  {
    path: "/login", //登录
    component: () => import("@/views/Login"),
    meta: {
      show: false,
      isAuther: false,
    },
  },
  {
    path: "/register", //祖册
    component: () => import("@/views/Register"),
    meta: {
      show: false,
      isAuther: false,
    },
  },
  {
    path: "/detail/:skuid", //商品详情
    component: () => import("@/views/Detail"),
    meta: {
      show: false,
      isAuther: false,
    },
  },
  {
    path: "/addcartsuccess", //购物车添加成功的路由
    name: "addcart",
    component: () => import("@/views/AddCartSuccess/index.vue"),
    meta: {
      show: false,
      isAuther: true,
    },
  },
  {
    path: "/shopcart", //购物车
    component: () => import("@/views/ShopCart/index.vue"),
    meta: {
      show: false,
      isAuther: true,
    },
  },
  {
    path: "/trade", //交易
    component: () => import("@/views/Trade/index.vue"),
    meta: {
      show: false,
      isAuther: true,
    },
    //组价内守卫
    beforeEnter: (to, from, next) => {
      //如果从购物车来
      if (from.path == "/shopcart") {
        next();
      } else {
        //中断当前导航
        next(false);
      }
    },
  },
  {
    path: "/pay", //支付
    component: () => import("@/views/Pay/index.vue"),
    meta: {
      show: false,
      isAuther: true,
    },
    //组件内守卫
    beforeEnter: (to, from, next) => {
      if (from.path == "/trade") {
        next();
      } else {
        next(false);
      }
    },
  },
  {
    path: "/paysuccess", //支付成功
    component: () => import("@/views/PaySuccess/index.vue"),
    meta: {
      show: false,
      isAuther: true,
    },
  },
  {
    path: "/center", //个人中心
    component: () => import("@/views/Center/index.vue"),
    redirect: "/center/myorder",
    meta: {
      show: false,
      isAuther: true,
    },
    children: [
      {
        path: "grouporder",
        component: () => import("@/views/Center/groupOrder"),
        meta: {
          show: false,
          isAuther: true,
        },
      },
      {
        path: "myorder",
        component: () => import("@/views/Center/myOrder"),
        meta: {
          show: false,
          isAuther: true,
        },
      },
    ],
  },
  //重定向
  {
    path: "/",
    redirect: "/home",
  },
];
